﻿package java_45;

import java.util.LinkedList;
import entity.NewTitle;

public class NewTitleDemo {

    public static void main(String[] args) {
     
      
        NewTitle car = new NewTitle(1, "汽车", "管理员");
        NewTitle medical = new NewTitle(2, "医学", "管理员");        
      
        LinkedList newsTitleList = new LinkedList();        
       
        newsTitleList.addFirst(car);
        newsTitleList.addLast(medical);
      
        NewTitle first = (NewTitle) newsTitleList.getFirst();
        System.out.println("头条的新闻标题为:" + first.getTitleName());
        NewTitle last = (NewTitle) newsTitleList.getLast();
        System.out.println("排在最后的新闻标题为:" + last.getTitleName());
        
        NewTitle firstNews=(NewTitle)newsTitleList.removeFirst();
        System.out.println("删除的头条新闻标题为:"+firstNews.getTitleName());
        NewTitle lastNews=(NewTitle)newsTitleList.removeLast();
        System.out.println("删除的末条新闻标题为:"+lastNews.getTitleName());
        System.out.println("删除后剩余的新闻条数："+newsTitleList.size());
    }
}